<?php
/**
 * Created by PhpStorm.
 * User: kongqi
 * Date: 2019/10/4
 * Time: 13:16
 */

namespace App\Plugin\HostServer\Models;

class PnHostSvGood extends HostServerBase
{
    public function systems()
    {
        return $this->hasMany(PnHostSvSystemGoods::class, 'good_id', 'id');
    }


    public function category()
    {
        return $this->hasOne(PnHostSvCategory::class, 'id', 'category_id');
    }

    public function level()
    {
        return $this->hasOne(PnHostSvCategory::class, 'id', 'config_level_id');
    }

    /**
     * 热门
     * @param $query
     * @param int $type
     * @return mixed
     */
    public function scopeHot($query,$type=1)
    {
        if($type)
        {
            return $query->where('is_hot',$type);
        }
        return $query;
    }
}